<?php

namespace app\common\service;

/**
 * 题目哈希标准化
 */
class QuestionHashService
{
    /**
     * build
     * @param $question
     * @return string
     */
    public static function build($question): string
    {
        $text = $question['questionAsk'];
        $allSelect = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'];
        foreach ($allSelect as $select) {
            if (!empty($question['answerOption'][$select])) {
                $text .= $question['answerOption'][$select];
            }
        }
        if (!empty($question['correctOption'])) {
            $text .= $question['correctOption'];
        }
        if (!empty($question['explanation'])) {
            $text .= $question['explanation'];
        }
        return md5($text);
    }
}